import './assets/main.css'

import { createApp } from 'vue'
import { createPinia } from 'pinia'

import App from './App.vue'
import router from './router'
import { renderWithQiankun, qiankunWindow } from "vite-plugin-qiankun/dist/helper.js"

let app

// app.use(createPinia())
// app.use(router)

if (!qiankunWindow.__POWERED_BY_QIANKUN__) {
  createApp(App).use(router).mount("#Mixingplant-container")
} else {
  renderWithQiankun({
    mount (props) {
      // 传递的值可以获取到了
      app = createApp(App)

      app.use(router).use(createPinia())
      app.mount(
        props.container
          ? props.container.querySelector("#Mixingplant-container")
          : document.getElementById("Mixingplant-container")
      )

      window.$props = props // 将props存储到全局变量中，方便其他组件访问
      //   qiankunWindow.$props.mainRouter.push("/Mixingplant/about");
    },
    bootstrap () {
      console.log("--bootstrap")
    },
    update (props) {
      console.log("--update", props)
    },
    unmount () {
      console.log("--unmount")
      app?.unmount()
    },
  })
}
